package net.orange.architecture.validator;

import java.util.Set;

/**
 * Validation : The set can't be empty.
 */
public class SetNotNullValidator extends ObjectValidator implements
		IObjectValidator {
	
	/**
	 * The field value
	 */
	private Set fieldValue;
	/**
	 * The field alias.
	 */
	private String fieldAlias;

	/**
	 * Disabled the default contractor.
	 */
	@SuppressWarnings("unused")
	private SetNotNullValidator() {

	}

	/**
	 * Constructor with fieldValue, fieldAlias.
	 * 
	 * @param fieldName
	 *            The target field value.
	 * @param fieldAlias
	 *            The target field alias.
	 */
	public SetNotNullValidator(Set fieldValue, String fieldAlias) {
		this.fieldValue = fieldValue;
		this.fieldAlias = fieldAlias;
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.orange.architecture.validator.ObjectValidator#getMessage()
	 */
	public String getMessage() {
		return "The " + fieldAlias + " cann't be empty";
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see net.orange.architecture.validator.ObjectValidator#check()
	 */
	public boolean check() throws Exception {
		return (fieldValue != null && fieldValue.size() > 0);
	}
}
